/*
 * @Description: 
 * @Autor: starzhou
 * @Date: 2020-09-04 23:26:27
 * @LastEditTime: 2020-09-04 23:28:21
 */
export const cloudChart = {
    methods: {
        drawCloud() {
            var data = {
                value: this.cloudData,
                image:
                    "",
            };
            var cloudChart = this.$echarts.init(
                document.getElementById("cloud-chart")
            );
            //温馨提示：image 选取有严格要求不可过大；，否则firefox不兼容 iconfont上面的图标可以
            var maskImage = new Image();
            maskImage.src = data.image;
            let i = 0;
            var colorArr = [
                "#098AE7",
                "#8A16E3",
                "#2F9BE9",
                "#CD1374",
                "#EEB1AD",
                "#75B575",
                "#C3DEBE",
                "#4194C7",
                "#C5BDE7",
            ];
            var option = {
                backgroundColor: "#fff",
                tooltip: {
                    show: false,
                },
                series: [
                    {
                        type: "wordCloud",
                        gridSize: 1,
                        sizeRange: [12, 55],
                        rotationRange: [-45, 0, 45, 90],
                        maskImage: maskImage,
                        textStyle: {
                            normal: {
                                color: function () {
                                    if (i === colorArr.length) {
                                        i = 0;
                                    }
                                    return colorArr[i++];
                                },
                            },
                        },
                        left: "center",
                        top: "center",
                        width: "96%",
                        right: null,
                        bottom: null,
                        data: data.value,
                    },
                ],
            };
            cloudChart.setOption(option);
        },
    },
}